<?php

namespace app\system\controller;

use app\system\model\MenuModel;
use think\App;

class Menu extends Base
{
    private $menuModel;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->menuModel = new MenuModel();
    }

    /**
     * 获取菜单列表
     */
    public function list(): \think\response\Json
    {
        $dataList = $this->menuModel
            ->order('parent_id, order_num')
            ->select()
            ->toArray();

        $returnData = [
            'code'=> 200,
            'msg'=> '操作成功',
            'data'=> $dataList
        ];
        return json($returnData);
    }

    /**
     * 根据菜单编号获取详细信息
     */
    public function getInfo()
    {
        $dataList = $this->menuModel
            ->order('by parent_id, order_num')
            ->select()
            ->toArray();

        $returnData = [
            'code'=> 200,
            'msg'=> '操作成功',
            'data'=> $dataList
        ];
        return json($returnData);
    }

    /**
     * 获取菜单下拉树列表
     */
    public function treeselect()
    {

    }

    /**
     * 加载对应角色菜单列表树
     */
    public function roleMenuTreeselect()
    {

    }

    /**
     * 新增菜单
     */
    public function add()
    {

    }

    /**
     * 修改菜单
     */
    public function edit()
    {

    }

    /**
     * 删除菜单
     */
    public function remove()
    {

    }

}